package com.hmy.contract.service.contract.create;

import cn.hutool.extra.spring.SpringUtil;
import com.hmy.ccp.error.exception.HMYRuntimeException;
import com.hmy.contract.commons.enums.ContractBusinessTypeEnum;
import com.hmy.contract.service.contract.create.feign.EntryElectronicContractCreateService;
import com.hmy.contract.service.contract.create.feign.ExitElectronicContractCreateService;
import com.hmy.contract.service.contract.create.feign.StatementOfAccountElectronicContractCreateService;
import com.hmy.contract.service.contract.create.lease.ElectronicLeaseContractCreateService;
import com.hmy.contract.service.contract.create.lease.PaperLeaseContractCreateService;
import com.hmy.contract.service.contract.create.supply.ElectronicSupplyContractCreateService;
import com.hmy.contract.service.contract.create.supply.PaperSupplyContractCreateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author seven.qi 齐胜南
 * @version 1.0
 * @description
 * @date 2023/12/23 16:12
 */
@Component
@Slf4j
public class ContractCreateServiceFactory {

    public static IContractCreateService getInstance(Integer businessType) {
        if (ContractBusinessTypeEnum.SALE_ELECTRONIC_CONTRACT.getType().equals(businessType)) {
            return SpringUtil.getBean(ElectronicLeaseContractCreateService.class);
        } else if (ContractBusinessTypeEnum.SALE_PAPER_CONTRACT.getType().equals(businessType)) {
            return SpringUtil.getBean(PaperLeaseContractCreateService.class);
        } else if (ContractBusinessTypeEnum.ENTRY_FORM_ELECTRONIC_CONTRACT.getType().equals(businessType)) {
            return SpringUtil.getBean(EntryElectronicContractCreateService.class);
        } else if (ContractBusinessTypeEnum.EXIT_FORM_ELECTRONIC_CONTRACT.getType().equals(businessType)) {
            return SpringUtil.getBean(ExitElectronicContractCreateService.class);
        } else if (ContractBusinessTypeEnum.SUPPLY_ELECTRONIC_CONTRACT.getType().equals(businessType)) {
            return SpringUtil.getBean(ElectronicSupplyContractCreateService.class);
        } else if (ContractBusinessTypeEnum.STATEMENT_OF_ACCOUNT_ELECTRONIC_CONTRACT.getType().equals(businessType)) {
            return SpringUtil.getBean(StatementOfAccountElectronicContractCreateService.class);
        } else if (ContractBusinessTypeEnum.SUPPLY_PAPER_CONTRACT.getType().equals(businessType)){
            return SpringUtil.getBean(PaperSupplyContractCreateService.class);
        } else {
            log.error("{} : not support", businessType);
            throw new HMYRuntimeException(502000031);
        }
    }
}
